//
//  TSDefaultCommonViewController.m
//  MirkoLibTest
//
//  Created by Mirko on 2017/3/20.
//  Copyright © 2017年 Mirko. All rights reserved.
//

#import "TSDefaultCommonViewController.h"
#import "UIView+MCFlagAttribute.h"
#import "MCTextAutoFillService.h"
#import "FileownerTestView.h"
#import "OwnerFile.h"

@interface TSDefaultCommonViewController () <MCTextAutoFillDelegate>

@property (nonnull, strong) MCTextAutoFillService *service;
@property (nonnull, strong) OwnerFile *owner;

@end

@implementation TSDefaultCommonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addRightBttonAction:nil];
    // Do any additional setup after loading the view.
}
- (IBAction)btn1Action:(id)sender {
    
    self.owner = [[OwnerFile alloc] init];
    
    
    NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"FileownerTestView" owner:self.owner options:nil];
    
    
    
    UIView *view = arr[0];
    view.frame = CGRectMake(0, 100, ScreenWidth(), 100);
    [self.view addSubview:view];
    
    
    
    self.owner.view = view;
    
    
    NSArray *arr1 = [[NSBundle mainBundle] loadNibNamed:@"FileownerTestView1" owner:self.owner options:nil];
    
    UIView *view1 = arr1[0];
    
    view1.frame = CGRectMake(0, 300, ScreenWidth(), 100);
    
    [self.view addSubview:view1];
    
    

    
}

- (IBAction)btn2Action:(id)sender {
    
}

- (IBAction)btn3Action:(id)sender {
}

-(void) handleRightBtnAction:(UIButton *)button
{
    if (self.view.mcViewFlag == nil) {
        DLOG(@"view flag is nil");
    }
    DLOG(@"%@", self.view.mcViewFlag);
    
    [self.service setValue:@"验证码" index:0 controller:self];
    [self.service setValue:@"测试数据" index:1 controller:self];
    [self.service setValue:@"测试数据" index:10 controller:self];
    
}

-(void) handelAction:(UINavigationController *)navController
{
    [navController pushViewController:self animated:YES];
}

-(void) viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    self.service = [[MCTextAutoFillService alloc] init];
    
    [self.service addAutoFillItem:self rootView:self.view];
//    [self listSubviewsOfView:self.view];
}

-(void) viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.service removeAutoFillItem:self];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSArray *) autoFillData:(UIViewController *) controller
{
    return [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
